package lt.marsrutai.mobile.android.model.enums;

public enum WeekdayType {
    MONDAY("monday"), TUESDAY("tuesday"), WEDNESDAY("wednesday"), THURSDAY("thursday"), FRIDAY("friday"), SATURDAY("saturday"), SUNDAY("sunday");

    private String value;

    WeekdayType(String value) {
        this.value = value;
    }

    public static WeekdayType parseEnum(String string) {
        for (WeekdayType weekdayType: values()) {
            if (weekdayType.toString().equals(string)) {
                return weekdayType;
            }
        }

        throw new IllegalArgumentException("Cannot parse enum WeekdayType from " + string);
    }

    public static WeekdayType parseEnumSunSat(int weekday) {
        switch (weekday) {
        case 0:
            return WeekdayType.SUNDAY;
        case 1:
            return WeekdayType.MONDAY;
        case 2:
            return WeekdayType.TUESDAY;
        case 3:
            return WeekdayType.WEDNESDAY;
        case 4:
            return WeekdayType.THURSDAY;
        case 5:
            return WeekdayType.FRIDAY;
        case 6:
            return WeekdayType.SATURDAY;
        default:
            throw new IllegalArgumentException("Cannot parse enum WeekdayType (Sun to Sat) from " + weekday);
        }
    }

    public static WeekdayType parseEnumMonSun(int weekday) {
        switch (weekday) {
        case 0:
            return WeekdayType.MONDAY;
        case 1:
            return WeekdayType.TUESDAY;
        case 2:
            return WeekdayType.WEDNESDAY;
        case 3:
            return WeekdayType.THURSDAY;
        case 4:
            return WeekdayType.FRIDAY;
        case 5:
            return WeekdayType.SATURDAY;
        case 6:
            return WeekdayType.SUNDAY;
        default:
            throw new IllegalArgumentException("Cannot parse enum WeekdayType (Mon to Sun) from " + weekday);
        }
    }

    @Override
    public String toString() {
        return value;
    }
}
